using JGSY.CMS.LowCode.Platform.Application.Interfaces;
using JGSY.CMS.LowCode.Platform.Application.DTOs;
using JGSY.CMS.LowCode.Platform.Infrastructure.Services.Notification;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Application.Services
{
    /// <summary>
    /// 短信应用服务
    /// 提供短信发送、验证码管理等通信相关业务功能
    /// 支持验证码发送、短信模板管理、发送状态跟踪等核心功能
    /// </summary>
    [JGSY.CMS.LowCode.Platform.Infrastructure.Services.LogOperation]
    public class SmsAppService : ISmsAppService
    {
        /// <summary>
        /// 短信服务接口
        /// </summary>
        private readonly Infrastructure.Services.Notification.ISmsService _smsService;

        /// <summary>
        /// 构造函数，注入短信服务
        /// </summary>
        /// <param name="smsService">短信服务接口</param>
        public SmsAppService(Infrastructure.Services.Notification.ISmsService smsService)
        {
            _smsService = smsService;
        }

        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="phone">目标手机号码</param>
        /// <param name="code">验证码内容</param>
        /// <returns>发送成功返回true，否则返回false</returns>
        public async Task<bool> SendSmsAsync(string phone, string code)
        {
            var result = await _smsService.SendVerificationCodeAsync(phone, code);
            return result.Success;
        }
    }
}
